package com.常用类.作业;

public class String反转 {
    public static void main(String[] args) {

        String str2 = "abcdefg";
        str2 = fz(str2, 1, str2.length()-1);
        System.out.println(str2);
    }


    static String fz(String str, int start, int end) {

        if(!(end <= str.length()-1 && start >= 0 && start <= str.length()-1)) {
            System.out.println("输入的下标不对,字符串未改动");
            return str;
        }
        char ch;
        char arr[] = str.toCharArray();
        for (int i = start, j = end; i < j; i++, j--) {
            ch = arr[i];
            arr[i] = arr[j];
            arr[j] = ch;
        }
        return new String(arr);
    }

}
